package Service;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class MusicService extends Service {
	private static final String TAG = "AudioService";
    MediaPlayer player;
    
    @Override
    public IBinder onBind(Intent intent){
        return null;
    }
    
    @Override
    public void onCreate(){
        Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show();
        Log.d(TAG, "onCreate");
        
        Uri path = Uri.parse("/storage/sdcard0/Music/IfYouAndMe-Juris_uge5.mp3");
        player = MediaPlayer.create(this, path);
        player.setLooping(false); // Set looping
    }
    
    @Override
    public void onDestroy(){
        Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show();
        Log.d(TAG, "onDestroy");
        player.stop();
    }
    
    @Override
    public void onStart(Intent intent, int startid)
    {
        Toast.makeText(this, "My serivce Started", Toast.LENGTH_LONG).show();
        Log.d(TAG, "onStart");
        player.start();
    }
}
